Let KeyText[19]="F-SHARP-MINOR" Let KeyText[20]="C-SHARP-MINOR" Let KeyText[21]="G-SHARP-MINOR" Let KeyText[22]="D-SHARP-MINOR" Let KeyText[23]="A-SHARP-MINOR" Let KeyText[24]="D-MINOR" Let KeyText[25]="G-MINOR" Let KeyText[26]="C-MINOR" Let KeyText[27]="F-MINOR" Let KeyText[28]="B-FLAT-MINOR" Let KeyText[29]="E-FLAT-MINOR" Let KeyText[30]="A-FLAT-MINOR" EndScript AfterAttachment ; used to be AfterStartup Nop ; Set font and style SetPrintFont "topaz",8 SetPrintStyle EMBOSSED ,2,0 SetPen 1,0 SetDrawMode JAM1 Nop ; Print text in window PrintText " Number of Measures:",200,23 PrintText "Max Note Duration Variation:",200,47 PrintText " Max Note Variation:",200,71 PrintText "Key:",16,28 PrintText "Timing:",16,67 Nop ; Load the music staff brush for later display LoadBrush "RCF:CanDo2.51/Brushes/MusicStaff.br","ClippedBrush" Transparent FALSE Nop ; Initialize time signature values and display them Let Beats=4 Let NoteBeat=4 Do "ShowTime" Nop ; Initialize key signature index and show it Let KeyTextIndex=1 Do "ShowKey" EndScript Window "UserWindow" Definition Origin 0,300 Size 640,100 Title "RandomNotes" NumberOfColors 16,69632 WindowColors 0,1,0 ; Detail, Block, Background WindowObjects CLOSEBUTTON DEPTHBUTTONS DRAGBAR WindowFlags ACTIVATE TOFRONT PUBLIC ,"DeluxeMusic" EndScript OnCloseButton Quit EndScript EndObject AreaButton "Key" Definition Origin 56,24 Size 136,16 Border ROLLO ,2,1 ; BorderStyle, MainPen, ExtraPen Highlight COMPLEMENT ButtonFlags NONE EndScript OnRelease Nop ; Calc next index, show it Let KeyTextIndex=KeyTextIndex//30+1 Do "ShowKey" EndScript EndObject IntegerField "NumMeasures" Definition Origin 432,24 Size 81,8 Justification RIGHT MaxFieldLength 4 Limits 1,1000 InitialInteger 4 Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "MaxNoteDurVar",ON EndScript EndObject IntegerField "MaxNoteDurVar" Definition Origin 432,48 Size 81,8 Justification RIGHT MaxFieldLength 1 Limits 0,6 InitialInteger 1 Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "MaxNoteVar",ON EndScript EndObject IntegerField "MaxNoteVar" Definition Origin 432,72 Size 81,8 Justification RIGHT MaxFieldLength 2 Limits 1,12 InitialInteger 2 Border DOUBLEBEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen EndScript OnRelease SetObjectState "NumMeasures",ON EndScript EndObject TextButton "Generate" Definition Origin 536,24 Font "topaz",8 ; FontName, PointSize PrintStyle SHADOW ,2,3 ; Style, Pen1, Pen2 TextColors 1,0,NORMAL ; PenA, PenB, DrawMode Text " Generate " Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen Highlight COMPLEMENT ButtonFlags NONE EndScript OnRelease Nop ; Clear current score and lock display SendMessage "CLEAR FORCE" SendMessage "LOCKDISPLAY" SendMessage "LOCKGUI" Nop ; Set key and time signatures SendMessage "SETKEYSIGNATURE "||KeyText[KeyTextIndex]||" 0 0" SendMessage "SETTIMESIGNATURE "||Beats||" "||NoteBeat||" 0" Nop ; Get user defined values from fields Let TotalBeats=Beats*IntegerFrom("NumMeasures") Let MNV=IntegerFrom("MaxNoteVar") Let MNDV=IntegerFrom("MaxNoteDurVar") Nop ; Initialize variables for loop Let NumBeats=0 Let NumBeatsMeasure=0 Let Line=0 Nop ; Loop until all measures filled While NumBeats<TotalBeats Nop ; Calc note line based on random variation Let LineVar=Random(-MNV,MNV) Let Line=Line+LineVar Nop ; Calc note beat based on random variation Let CurNoteBeatVar=Random(-MNDV,MNDV) Let CurNoteBeat=Integer(NoteBeat*(2^CurNoteBeatVar)) Nop ; Make sure note beat is within acceptable range 1-64 Let CurNoteBeat=Min(64,Max(1,CurNoteBeat)) Nop ; Make sure notes near end of measure do not exceed Nop ; maximum allowable While (NumBeatsMeasure+NoteBeat/CurNoteBeat)>Beats Let CurNoteBeat=CurNoteBeat*2 EndLoop Nop ; Insert the note and go to next position SendMessage "INSERTITEM NOTE DURATION "||CurNoteBeat||" LINE "||Line SendMessage "NEXT NOTE" Nop ; Update the number of current beats in the song and Nop ; the current measure Let NumBeats=NumBeats+NoteBeat/CurNoteBeat Let NumBeatsMeasure=NumBeatsMeasure+NoteBeat/CurNoteBeat Nop ; Go to next measure if current one full If NumBeatsMeasure>=Beats SendMessage "NEXT MEASURE" Let NumBeats=Integer(NumBeats) Let NumBeatsMeasure=0 EndIf EndLoop Nop ; Unlock the display, activate song window, Nop ; update the display, and go to the first measure SendMessage "UNLOCKGUI" SendMessage "UNLOCKDISPLAY" SendMessage "WINDOW DOCUMENT ACTIVATE" SendMessage "UPDATEDISPLAY" SendMessage "POSITION SOF" EndScript EndObject TextButton "Play" Definition Origin 536,48 Font "topaz",8 ; FontName, PointSize PrintStyle SHADOW ,2,3 ; Style, Pen1, Pen2 TextColors 1,0,NORMAL ; PenA, PenB, DrawMode Text " Play " Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen Highlight COMPLEMENT ButtonFlags NONE EndScript OnRelease Nop ; Activate the song window and play song SendMessage "WINDOW DOCUMENT ACTIVATE" SendMessage "PLAY" EndScript EndObject TextButton "Stop" Definition Origin 536,72 Font "topaz",8 ; FontName, PointSize PrintStyle SHADOW ,2,3 ; Style, Pen1, Pen2 TextColors 1,0,NORMAL ; PenA, PenB, DrawMode Text " Stop " Border BEVEL ,2,1 ; BorderStyle, MainPen, ExtraPen Highlight COMPLEMENT ButtonFlags NONE EndScript OnRelease Nop ; Stop playing the song SendMessage "STOP" EndScript EndObject ImageButton "BeatsLeft" Definition Origin 110,60 Image "RCF:CanDo2.51/Brushes/Left.br" Highlight COMPLEMENT ButtonFlags NONE EndScript OnClick Nop ; Change beats while pressing button Nop ; Do not allow value below 1 Loop Let Beats=Max(Beats-1,1) Do "ShowTime" Delay 0,0,10 Until ObjectState("BeatsLeft")=OFF EndScript EndObject ImageButton "BeatsRight" Definition Origin 132,60 Image "RCF:CanDo2.51/Brushes/Right.br" Highlight COMPLEMENT ButtonFlags NONE EndScript OnClick Nop ; Change beats while pressing button Nop ; Do not allow value above 16 Loop Let Beats=Min(Beats+1,16) Do "ShowTime" Delay 0,0,10 Until ObjectState("BeatsRight")=OFF EndScript EndObject ImageButton "NoteBeatLeft" Definition Origin 110,72 Image "RCF:CanDo2.51/Brushes/Left.br" Highlight COMPLEMENT ButtonFlags NONE EndScript OnClick Nop ; Change beats while pressing button Nop ; Do not allow value below 1 Loop Let NoteBeat=Max(NoteBeat/2,1) Do "ShowTime" Delay 0,0,10 Until ObjectState("NoteBeatLeft")=OFF EndScript EndObject ImageButton "NoteBeatRight" Definition Origin 132,72 Image "RCF:CanDo2.51/Brushes/Right.br" Highlight COMPLEMENT ButtonFlags NONE EndScript OnClick Nop ; Change beats while pressing button Nop ; Do not allow value above 64 Loop Let NoteBeat=Min(NoteBeat*2,64) Do "ShowTime" Delay 0,0,10 Until ObjectState("NoteBeatRight")=OFF EndScript EndObject* End of Card "DMCard"*************************** Global routine "ShowKey" Nop ; Set font and style SetPrintFont "topaz",8 SetPrintStyle PLAIN ,2,3 SetPen 1,0 SetDrawMode JAM2 Nop ; Erase current key in rollo button PrintText " ",83,28 Nop ; Print the new key based on current index PrintText KeyText[KeyTextIndex],83,28* End of routine "ShowKey"*************************** Global routine "ShowTime" Nop ; Show the music staff brush ShowBrush "ClippedBrush",79,61 Nop ; Set font and style SetPrintFont "topaz",9 SetPrintStyle BOLD OUTLINE ,2,3 SetPen 1,0 SetDrawMode JAM1 Nop ; Print the top and bottom number of time signature Nop ; Note the different position if number is two digits PrintText Beats,83-4*(Beats>=10),62 PrintText NoteBeat,83-4*(NoteBeat>=10),72* End of routine "ShowTime"*************╓╜ ₧╠lS%dΦpⁿX╤ }/Ä6Éh▐ù╥SΓa╤G>ΦΣpÆIë±F?¿ù